package com.show.service.role;

import com.show.dao.role.RoleMenuRepository;
import com.show.dto.sys_role.SysRoleMenu;
import com.show.util.QueryUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author yxd
 * @Param
 * @date 2018-2-1
 */
@Service
@Transactional
public class RoleMenuService {
    @Autowired
    private RoleMenuRepository roleMenuRepository;
    @Autowired
    private QueryUtil queryUtil;

    /**
     * 查询该角色对应菜单
     *
     * @param roleId
     * @author yxd
     * @date 2018/02/1
     */
    public List<SysRoleMenu> findAllByRoleId(String roleId) {
        String sql="select role_menu_id,role_id,menu_id from sys_role_menu where role_id='"+roleId+"' ORDER BY role_menu_id";
        List<SysRoleMenu> list=queryUtil.query(sql.toString(),SysRoleMenu.class);
        return list;
    }

    /**
     * 删除该角色对应菜单
     *
     * @param roleId
     * @author yxd
     * @date 2018/02/1
     */
    public void delete(int roleId) {
        roleMenuRepository.delete(String.valueOf(roleId));
    }



}
